﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using VipReminder.ViewModel;
using VipReminder.Views;
using Window = System.Windows.Window;

namespace VipReminder
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow
    {
        private VmReminder _vm;

        public MainWindow()
        {
            InitializeComponent(); 
            _vm = new VmReminder();
            DataContext = _vm;
             
            this.Topmost = true; //窗体最前端显示
        }



        private void DockContainer_OnDragMove(object sender, MouseButtonEventArgs e)
        {
            switch (e.ClickCount)
            {
                // Background="White"  不加这个属性，不能拖拽
                case 1://单击
                    {
                        //if (e.LeftButton == MouseButtonState.Pressed)
                        //{
                        //    if (WindowState == WindowState.Maximized)
                        //    {
                        //        WindowState = WindowState.Normal;
                        //    }
                        //}
                        this.DragMove();
                        break;
                    }
                case 2://双击
                    {
                        MaxButton_Click(null, null);
                        TopMaxButton.IsChecked = WindowState == WindowState.Maximized;
                        break;
                    }
            }
        }


        private void Close_OnClick(object sender, RoutedEventArgs e)
        {
           this.Close();
        }


        private void MinButton_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void Help_Click(object sender, RoutedEventArgs e)
        {
            About about=new About();
            
            about.ShowDialog();
        }

        private void MaxButton_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
        }


        private void OpenWeb_OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            Process.Start(new ProcessStartInfo("http://www.vipsoft.com.cn"));
        }

        // 定时器
        private DispatcherTimer _timer;

        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            _vm.IsHourly = chkHourly.IsChecked.HasValue && chkHourly.IsChecked.Value;
            _vm.WorkValue = (int)numWork.Value;
            _vm.BreakValue = (int)numBreak.Value;

            CountDown countDown = new CountDown();
            countDown.DataContext = this._vm;
            countDown.InitData();
            Application.Current.MainWindow = countDown;
            countDown.Show();
            this.Close();
        }

    }
}
